package com.leyou.item.controller;

import com.leyou.common.enums.ItemExceptionEnum;
import com.leyou.common.exceptions.LyException;
import com.leyou.item.service.ItemService;
import com.leyou.pojo.Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version V1.0
 * @author: Ljxpa
 * @date: 2020/03/02 20:14
 * @description:
 */
@RestController
public class ItemController {

	@Autowired
	private ItemService itemService;

	@PostMapping("/add")
	public Item add(Item item) {
		if(item.getPrice()==null){
			throw new LyException(ItemExceptionEnum.PRICE_CANNOT_BE_NULL);
		}
		return itemService.add(item);
	}
}
